home *** CD-ROM | disk | FTP | other *** search
/ Champak 52 / Volume 52 - JOGO DISK .iso / Games / shopdrop.swf / scripts / __Packages / ShopHandler.as < prev    next >
Text File  |  2007-09-27  |  2KB  |  73 lines

  1. class ShopHandler
  2. {
  3.    var scrollSpeed = 200;
  4.    var buildingSpace = 260;
  5.    var nBuildings = 64;
  6.    var cBuildings = 0;
  7.    function ShopHandler(loc)
  8.    {
  9.       this.aClips = [];
  10.       this.location = loc;
  11.       this.lastBuilding = this.addClip("mcBuildingLeft");
  12.       this.render();
  13.    }
  14.    function update(nElapsed)
  15.    {
  16.       var _loc5_ = this.scrollSpeed * nElapsed;
  17.       var _loc4_ = this.aClips;
  18.       var _loc6_ = _loc4_.length;
  19.       var _loc3_ = undefined;
  20.       var _loc2_ = 0;
  21.       while(_loc2_ < _loc6_)
  22.       {
  23.          _loc3_ = _loc4_[_loc2_];
  24.          if(_loc3_ != null)
  25.          {
  26.             _loc3_.pos.x += _loc5_;
  27.          }
  28.          _loc2_ = _loc2_ + 1;
  29.       }
  30.       if(this.lastBuilding.pos.z > this.buildingSpace)
  31.       {
  32.          this.lastBuilding = this.addClip("mcBuildingLeft");
  33.       }
  34.    }
  35.    function render()
  36.    {
  37.       var _loc4_ = this.aClips;
  38.       var _loc5_ = _loc4_.length;
  39.       var _loc3_ = undefined;
  40.       var _loc2_ = 0;
  41.       while(_loc2_ < _loc5_)
  42.       {
  43.          _loc3_ = _loc4_[_loc2_];
  44.          if(_loc3_ != null)
  45.          {
  46.             _loc3_.render();
  47.          }
  48.          _loc2_ = _loc2_ + 1;
  49.       }
  50.    }
  51.    function addClip(sId)
  52.    {
  53.       var _loc3_ = this.aClips.length;
  54.       this.cBuildings = ++this.cBuildings % this.nBuildings;
  55.       var _loc2_ = this.location.attachMovie(sId,"clip" + this.cBuildings,_loc3_);
  56.       _loc2_.handler = this;
  57.       _loc2_.render();
  58.       this.aClips.push(_loc2_);
  59.       return _loc2_;
  60.    }
  61.    function removeClip(clip)
  62.    {
  63.       this.aClips.splice(0,1);
  64.       clip.removeMovieClip();
  65.       var _loc2_ = 0;
  66.       while(_loc2_ < this.aClips.length)
  67.       {
  68.          this.aClips[_loc2_].swapDepths(_loc2_);
  69.          _loc2_ = _loc2_ + 1;
  70.       }
  71.    }
  72. }
  73.